<template>
	<view>
		<!-- tab -->
		<u-sticky>
		<view class="tab-box">
			<u-tabs bg-color="#ffffff" :is-scroll="false" inactive-color="#999" name="tab_name" :list="tabs" active-color="#616161" c :current="current" @change="tabChange"></u-tabs>
		</view>
		</u-sticky>
		<view class='p-20'>
			<auditing-task-list :handle="true" :list="list" :isShowUser="false" :loadStatus="loadStatus"></auditing-task-list>
		</view>
	</view>
</template>

<script>
import auditingTaskList from '../../components/auditing-list/auditing-task-list.vue';
export default {
	components: {
		auditingTaskList
	},
	data() {
		return {
			tabs: [{
					tab_name: '审核中',
					tab_value:0
				},{
					tab_name: '展示中',
					tab_value:1
				},{
					tab_name: '已关闭',
					tab_value:2
				},{
					tab_name: '审核失败',
					tab_value:3
				}
			],
			current: 0,
			page: 1,
			list: [],
			loadStatus: 'loading',
		};
	},
	onLoad() {
		this.getList();
	},
	onReachBottom() {
		if(this.loadStatus!='nomore') {
			this.page++;
			this.loadStatus = 'loading'
			this.getList();
		}
	},
	onPullDownRefresh() {
		this.List = [];
		this.page       = 1;
		this.loadStatus = 'loading';
		this.getList();
	},
	methods: {
		tabChange(index) {
			if(this.current===index) return;
			this.current = index;
			this.page = 1;
			this.loadStatus = 'loading';
			this.list = [];
			this.getList();
		},
		async getList() {
			this.loadStatus = 'loading';
			let res = await this.$api('task')
			this.list = this.list.concat(res.data.list);
			if (this.page === res.data.total_pages || res.data.total_pages === 0) {
				this.loadStatus = 'nomore';
			} else {
				this.loadStatus = 'loadmore';
			}
		}
	}
};
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>
